<template>
  <div class="questions-check">
    <el-form ref="checkRuleFormRef" :model="checkRuleForm" :rules="rules">
      <el-form-item prop="resource">
        <el-radio-group v-model="radio">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item prop="desc">
        <el-input
          placeholder="请输入审核意见"
          type="textarea"
          v-model="checkRuleForm.desc"
        ></el-input>
      </el-form-item>
      <el-form-item class="btn-wrap">
        <el-button @click="cancelClick()">取 消</el-button>
        <el-button type="primary" @click="updataClick">确 定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { choiceCheck } from "../../api/hmmm/questions";

export default {
  name: "QuestionsCheck",
  components: {},
  props: {
    rowID: {
      type: [Number, String],
      required: true
    }
  },
  data() {
    return {
      checkRuleForm: { desc: "" },
      rules: {
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }]
        // resource: [
        //   { required: true, message: "请选择审核状态", trigger: "change" }
        // ]
      },
      radio: 1
    };
  },
  created() {},
  mounted() {},
  computed: {},
  methods: {
    // 取消按钮
    cancelClick() {
      this.$emit("update:checkDialogVisible", false);
    },
    // 确定按钮
    updataClick() {
      console.log(this.radio);
      this.$refs.checkRuleFormRef.validate(async valid => {
        if (valid) {
          await choiceCheck({
            id: this.rowID,
            chkState: Number(this.radio),
            chkRemarks: this.checkRuleForm.desc
          });
          // console.log(this.rowID, Number(this.radio), this.checkRuleForm.desc);
          this.$message.success("恭喜你，这是一条成功消息");
          this.$emit("update:checkDialogVisible", false);
          this.$emit("input");
        } else {
          console.log("error submit!!");
          this.$message({
            message: "警告哦，这是一条警告消息",
            type: "warning"
          });
          this.$emit("update:checkDialogVisible", true);
          return false;
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.questions-check {
  .btn-wrap {
    display: flex;
    justify-content: flex-end;
  }
}
</style>
